Skip to content

Increases test coverage. #446

Merged
marvin-hansen merged 8 commits intodeepcausality-rs:mainfrom
marvin-hansen:main
Jan 8, 2026
Merged

Increases test coverage. #446
marvin-hansen merged 8 commits intodeepcausality-rs:mainfrom
marvin-hansen:main

Conversation

@marvin-hansen
Copy link
Copy Markdown
Member

@marvin-hansen marvin-hansen commented Jan 8, 2026

User description

Describe your changes

Increases test coverage.

Issue ticket number and link

Code checklist before requesting a review

  • I have signed the DCO?
  • All tests are passing when running make test?
  • No errors or security vulnerabilities are reported by make check?

For details on make, please see BUILD.md

Note: The CI runs all of the above and fixing things before they hit CI speeds
up the review and merge process. Thank you.


PR Type

Tests, Enhancement


Description

  • Added comprehensive test coverage for Higher-Kinded Type (HKT) operations in deep_causality_topology:

    • Expanded hkt_manifold_tests.rs with tests for Pure, Foldable, and Monad trait implementations
    • Added hkt_simplicial_complex_tests.rs with Functor and Foldable trait tests for Chain structures
  • Updated third-party dependencies with newer versions:

    • Upgraded libc from 0.2.177 to 0.2.180 with comprehensive platform bindings for Unix, Linux, Cygwin, and other platforms
    • Upgraded zerocopy from 0.8.30 to 0.8.33
    • Upgraded parquet from 56.2.0 to 57.1.0
    • Upgraded cc from 1.2.47 to 1.2.51 with refactored process spawning and enhanced debug flag handling
    • Upgraded rustix, syn, bumpalo, wasm-bindgen, and other dependencies
  • Enhanced cc crate with improved process handling and debug configuration options


Diagram Walkthrough

flowchart LR
  A["Test Coverage<br/>HKT Traits"] -->|"Functor, Monad,<br/>Foldable"| B["deep_causality_topology<br/>Tests"]
  C["Third-party<br/>Dependencies"] -->|"libc, zerocopy,<br/>parquet, cc, rustix"| D["Updated Crates<br/>Versions"]
  E["cc Crate<br/>Enhancements"] -->|"Process spawning,<br/>Debug flags"| D
Loading

File Walkthrough

Relevant files
Enhancement
4 files
mod.rs
Add complete Cygwin platform bindings and system definitions

thirdparty/crates/libc-0.2.180/src/unix/cygwin/mod.rs

  • Added comprehensive Cygwin platform definitions including type aliases
    for C types (wchar_t, blkcnt_t, dev_t, etc.)
  • Defined numerous struct types for system interfaces (stat, passwd,
    sockaddr, termios, ucontext_t, etc.)
  • Added extensive constant definitions for signals, socket options, file
    operations, and POSIX compliance flags
  • Implemented inline functions for file descriptor operations (FD_CLR,
    FD_SET, FD_ZERO) and CPU set manipulation
  • Added extern C function declarations for system calls and library
    functions (pthread, socket, file I/O, etc.)
+2388/-0
mod.rs
Add comprehensive Unix libc definitions and FFI bindings 

thirdparty/crates/libc-0.2.180/src/unix/mod.rs

  • Added comprehensive Unix module with type definitions for common Unix
    types (intmax_t, size_t, pid_t, etc.)
  • Defined struct types for Unix data structures (group, timeval, stat,
    rusage, ipv6_mreq, etc.)
  • Declared numerous C FFI function bindings for Unix system calls and
    library functions (file I/O, process management, networking,
    threading, etc.)
  • Configured platform-specific linking directives for various Unix-like
    operating systems (Linux, macOS, BSD, Solaris, etc.)
  • Implemented safe wrapper functions for byte order conversion (htonl,
    htons, ntohl, ntohs)
+2418/-0
tool.rs
Refactor process spawning and enhance debug flag handling

thirdparty/crates/cc-1.2.51/src/tool.rs

  • Replaced spawn function call with spawn_and_wait_for_output to
    simplify child process handling
  • Removed manual stdout/stderr reading logic and child.wait() call, now
    using Output struct directly
  • Enhanced add_debug_flags method to accept debug_opt parameter and
    handle multiple debug levels (0, 1, 2, limited, full,
    line-directives-only)
  • Added new warnings_suppression_flags method to return
    platform-specific warning suppression flags
  • Updated imports to include Output type and remove Read trait
+51/-20 
mod.rs
Add comprehensive Linux-like platform bindings and definitions

thirdparty/crates/libc-0.2.180/src/unix/linux_like/mod.rs

  • Added comprehensive Linux-like platform type definitions and constants
    for socket, network, and system operations
  • Defined struct types for network protocols (in_addr, sockaddr,
    addrinfo), file operations (epoll_event), and system utilities (tm,
    utsname)
  • Implemented ioctl command builders (_IO, _IOR, _IOW, _IOWR) with
    architecture-specific bit configurations
  • Added extensive constant definitions for signals, file modes, socket
    options, IP protocols, and filesystem magic numbers
  • Included helper macros and functions for file descriptor operations
    (FD_SET, FD_CLR, FD_ISSET), message handling (CMSG_*), and process
    status checking (WIFEXITED, WTERMSIG)
  • Declared extern C functions for system calls and library functions
    related to time, file operations, networking, and process management
+2205/-0
Tests
2 files
hkt_manifold_tests.rs
Expand HKT manifold test coverage with monad and foldable tests

deep_causality_topology/tests/extensions/hkt_manifold_tests.rs

  • Updated imports to include Foldable, Monad, and Pure traits from
    deep_causality_haft
  • Added test_manifold_pure() to verify Pure::pure wraps values into a
    minimal Manifold
  • Added test_manifold_fold() to test the Foldable trait implementation
    with sum accumulation
  • Added test_manifold_bind() to test the Monad trait implementation with
    value transformation
  • Added test_manifold_apply_via_functor() to exercise functor and
    applicative code paths
  • Removed test_manifold_extract_empty_panics test with explanatory note
    about API constraints
+59/-1   
hkt_simplicial_complex_tests.rs
Add HKT functor and foldable trait tests for coverage       

deep_causality_topology/tests/extensions/hkt_simplicial_complex_tests.rs

  • Added import of Foldable and Functor traits from deep_causality_haft
    module
  • Implemented five new test functions covering Higher-Kinded Type (HKT)
    operations on Chain structures
  • Tests validate Functor::fmap operations including value doubling and
    type conversion (f64 to i32)
  • Tests validate Foldable::fold operations including sum computation,
    product computation, and string concatenation
+92/-1   
Additional files
101 files
example.sh +0/-84   
mod.rs +0/-7     
Cargo.toml +1/-2     
README.md +1/-21   
lib.rs +0/-160 
BUILD.bazel +0/-16   
collections_tests.rs +0/-165 
mod.rs +0/-7     
BUILD.bazel +1/-0     
BUILD.bazel +5/-0     
debug.rs +1/-1     
display.rs +2/-2     
traits_num.rs +1/-1     
complex_field_tests.rs +300/-0 
mod.rs +4/-0     
ordering_tests.rs +148/-0 
double_algebra_tests.rs +264/-0 
double_arithmetic_tests.rs +255/-0 
double_attributes_tests.rs +166/-0 
double_comparison_tests.rs +223/-0 
double_display_tests.rs +162/-0 
double_float_tests.rs +391/-0 
double_from_tests.rs +206/-0 
double_num_traits_tests.rs +284/-0 
mod.rs +16/-0   
integer_all_types_tests.rs +255/-0 
mod.rs +3/-0     
signed_all_types_tests.rs +205/-0 
unsigned_all_types_tests.rs +160/-0 
BUILD.bazel +2/-1     
em_tests.rs +150/-0 
mod.rs +6/-0     
electroweak_tests.rs +554/-0 
mod.rs +8/-0     
radiative_tests.rs +248/-0 
electroweak_tests.rs +0/-381 
gr_tests.rs +869/-0 
mod.rs +6/-0     
gr_tests.rs +0/-535 
mod.rs +4/-8     
mod.rs +6/-0     
weak_force_tests.rs [link]   
lib.rs +1/-1     
mod.rs +2/-2     
BUILD.bazel +1/-0     
topology_error_tests.rs +26/-1   
hkt_gauge_field_tests.rs +294/-11
cell_complex_homology_tests.rs +163/-0 
mod.rs +2/-0     
gauge_field_tests.rs +9/-8     
gauge_field_validation_tests.rs +124/-0 
mod.rs +2/-0     
makefile +0/-7     
BUILD.bazel +2/-2     
BUILD.bazel +6/-6     
BUILD.bazel +1/-1     
BUILD.bazel +1/-1     
.cargo-checksum.json +0/-1     
.cargo_vcs_info.json +0/-6     
BUILD.bazel +0/-99   
CHANGELOG.md +0/-861 
Cargo.toml +0/-88   
Cargo.toml.orig +0/-68   
lib.rs +0/-2639
.cargo-checksum.json +1/-0     
.cargo_vcs_info.json +6/-0     
BUILD.bazel +99/-0   
CHANGELOG.md +876/-0 
Cargo.toml +94/-0   
Cargo.toml.orig +72/-0   
LICENSE-APACHE [link]   
LICENSE-MIT [link]   
README.md [link]   
alloc.rs [link]   
boxed.rs [link]   
collect_in.rs [link]   
mod.rs [link]   
raw_vec.rs [link]   
lossy.rs [link]   
mod.rs [link]   
string.rs +1/-0     
vec.rs +11/-3   
lib.rs +2639/-0
.cargo-checksum.json +0/-1     
.cargo_vcs_info.json +0/-6     
BUILD.bazel +0/-100 
CHANGELOG.md +0/-686 
Cargo.toml +0/-79   
Cargo.toml.orig +0/-59   
README.md +0/-27   
lib.rs +0/-4447
.cargo-checksum.json +1/-0     
.cargo_vcs_info.json +6/-0     
BUILD.bazel +100/-0 
CHANGELOG.md +715/-0 
Cargo.toml +79/-0   
Cargo.toml.orig +59/-0   
LICENSE-APACHE [link]   
LICENSE-MIT [link]   
README.md +29/-0   
Additional files not shown

Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
@marvin-hansen marvin-hansen self-assigned this Jan 8, 2026
@socket-security
Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedcargo/​num_cpus@​1.16.0 ⏵ 1.17.010010093100100

View full report

@qodo-code-review
Copy link
Copy Markdown
Contributor

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
Panic-based DoS

Description: The new CPU_SET/CPU_CLR/CPU_ISSET helpers index cpuset.bits[idx] without validating idx,
so a large cpu value can trigger an out-of-bounds panic and cause a denial-of-service if
cpu can be influenced by untrusted input.
linux_l4re_shared.rs [1531-1547]

Referred Code
pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
    let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc
    let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
    cpuset.bits[idx] |= 1 << offset;
}

pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
    let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc
    let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
    cpuset.bits[idx] &= !(1 << offset);
}

pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
    let size_in_bits = 8 * size_of_val(&cpuset.bits[0]);
    let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
    0 != (cpuset.bits[idx] & (1 << offset))
}
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@marvin-hansen marvin-hansen merged commit bbf34ff into deepcausality-rs:main Jan 8, 2026
10 of 13 checks passed
@qodo-code-review
Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix incorrect struct packing for ABI

Replace #[repr(packed(4))] with #[repr(C)] on the shmid_ds struct to fix memory
mis-alignment and prevent undefined behavior on 64-bit Apple targets.

thirdparty/crates/libc-0.2.180/src/unix/bsd/apple/mod.rs [1293-1305]

-#[repr(packed(4))]
+#[repr(C)]
 pub struct shmid_ds {
     pub shm_perm: ipc_perm,
     pub shm_segsz: size_t,
     pub shm_lpid: crate::pid_t,
     pub shm_cpid: crate::pid_t,
     pub shm_nattch: crate::shmatt_t,
-    pub shm_atime: crate::time_t, // FIXME(macos): 64-bit wrong align => wrong offset
-    pub shm_dtime: crate::time_t, // FIXME(macos): 64-bit wrong align => wrong offset
-    pub shm_ctime: crate::time_t, // FIXME(macos): 64-bit wrong align => wrong offset
-    // FIXME: 64-bit wrong align => wrong offset:
+    pub shm_atime: crate::time_t,
+    pub shm_dtime: crate::time_t,
+    pub shm_ctime: crate::time_t,
     pub shm_internal: *mut c_void,
 }
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies that #[repr(packed(4))] on shmid_ds will cause unaligned memory access on 64-bit systems, which is undefined behavior. Replacing it with #[repr(C)] is the correct fix for this critical ABI compatibility issue.

High
Avoid undefined behavior in union comparison

Fix undefined behavior in the PartialEq implementation for the
__c_anonymous_ifr_ifru union by performing a safe byte-wise comparison.

thirdparty/crates/libc-0.2.180/src/unix/bsd/freebsdlike/freebsd/mod.rs [1833-1853]

 impl PartialEq for __c_anonymous_ifr_ifru {
     fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool {
         unsafe {
-            self.ifru_addr == other.ifru_addr
-                && self.ifru_dstaddr == other.ifru_dstaddr
-                && self.ifru_broadaddr == other.ifru_broadaddr
-                && self.ifru_buffer == other.ifru_buffer
-                && self.ifru_flags == other.ifru_flags
-                && self.ifru_index == other.ifru_index
-                && self.ifru_jid == other.ifru_jid
-                && self.ifru_metric == other.ifru_metric
-                && self.ifru_mtu == other.ifru_mtu
-                && self.ifru_phys == other.ifru_phys
-                && self.ifru_media == other.ifru_media
-                && self.ifru_data == other.ifru_data
-                && self.ifru_cap == other.ifru_cap
-                && self.ifru_fib == other.ifru_fib
-                && self.ifru_vlan_pcp == other.ifru_vlan_pcp
+            let s: &[u8] =
+                core::slice::from_raw_parts(self as *const _ as *const u8, core::mem::size_of_val(self));
+            let o: &[u8] =
+                core::slice::from_raw_parts(other as *const _ as *const u8, core::mem::size_of_val(other));
+            s == o
         }
     }
 }
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies that accessing multiple fields of a union is undefined behavior and provides a safe, byte-wise comparison to fix this critical memory safety issue.

High
Avoid undefined behavior in union hashing

Fix undefined behavior in the Hash implementation for the __c_anonymous_ifr_ifru
union by hashing its raw byte representation.

thirdparty/crates/libc-0.2.180/src/unix/bsd/freebsdlike/freebsd/mod.rs [1855-1873]

 impl hash::Hash for __c_anonymous_ifr_ifru {
     fn hash<H: hash::Hasher>(&self, state: &mut H) {
-        unsafe { self.ifru_addr.hash(state) };
-        unsafe { self.ifru_dstaddr.hash(state) };
-        unsafe { self.ifru_broadaddr.hash(state) };
-        unsafe { self.ifru_buffer.hash(state) };
-        unsafe { self.ifru_flags.hash(state) };
-        unsafe { self.ifru_index.hash(state) };
-        unsafe { self.ifru_jid.hash(state) };
-        unsafe { self.ifru_metric.hash(state) };
-        unsafe { self.ifru_mtu.hash(state) };
-        unsafe { self.ifru_phys.hash(state) };
-        unsafe { self.ifru_media.hash(state) };
-        unsafe { self.ifru_data.hash(state) };
-        unsafe { self.ifru_cap.hash(state) };
-        unsafe { self.ifru_fib.hash(state) };
-        unsafe { self.ifru_vlan_pcp.hash(state) };
+        unsafe {
+            let s: &[u8] =
+                core::slice::from_raw_parts(self as *const _ as *const u8, core::mem::size_of_val(self));
+            s.hash(state);
+        }
     }
 }
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies that accessing multiple fields of a union is undefined behavior and provides a safe, byte-wise hashing implementation to fix this critical memory safety issue.

High
Fix panicking hash implementation

Implement the hash function for __c_anonymous_elf32_auxv_union to hash the a_val
field instead of panicking.

thirdparty/crates/libc-0.2.180/src/unix/bsd/freebsdlike/freebsd/mod.rs [1827-1831]

 impl hash::Hash for __c_anonymous_elf32_auxv_union {
-    fn hash<H: hash::Hasher>(&self, _state: &mut H) {
-        unimplemented!("traits");
+    fn hash<H: hash::Hasher>(&self, state: &mut H) {
+        unsafe { self.a_val.hash(state) };
     }
 }
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: The suggestion fixes a panicking hash implementation, which is a latent bug that would crash the program if the type were used in a hash-based collection.

Medium
Add repr(C) to union

Add #[repr(C)] to the __c_anonymous_cr_pid union to ensure a C-compatible memory
layout for FFI.

thirdparty/crates/libc-0.2.180/src/unix/bsd/freebsdlike/freebsd/mod.rs [1656-1659]

+#[repr(C)]
 pub union __c_anonymous_cr_pid {
     __cr_unused: Padding<*mut c_void>,
     pub cr_pid: crate::pid_t,
 }
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly points out the missing #[repr(C)] on a union intended for FFI, which is crucial for ensuring a defined memory layout and preventing potential issues.

Medium
Use repr(C, packed) on structs

Add #[repr(C)] to the sctphdr struct, combining it with #[repr(packed)] for FFI
safety and guaranteed field order.

thirdparty/crates/libc-0.2.180/src/unix/bsd/freebsdlike/freebsd/mod.rs [1555-1561]

-#[repr(packed)]
+#[repr(C, packed)]
 pub struct sctphdr {
     pub src_port: u16,
     pub dest_port: u16,
     pub v_tag: u32,
     pub checksum: u32,
 }
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly advises adding #[repr(C)] to a #[repr(packed)] struct to guarantee field ordering, which is important for FFI correctness.

Medium
General
derive enum equality

Derive PartialEq and Eq for the sysdir_search_path_directory_t enum to enable
equality comparisons and remove the redundant manual Copy and Clone
implementations.

thirdparty/crates/libc-0.2.180/src/unix/bsd/apple/mod.rs [186-219]

-#[derive(Debug)]
+#[derive(Debug, PartialEq, Eq)]
 #[repr(u32)]
 pub enum sysdir_search_path_directory_t {
     SYSDIR_DIRECTORY_APPLICATION = 1,
     /* ... */
 }
-impl Copy for sysdir_search_path_directory_t {}
-impl Clone for sysdir_search_path_directory_t {
-    fn clone(&self) -> sysdir_search_path_directory_t {
-        *self
-    }
-}
  • Apply / Chat
Suggestion importance[1-10]: 5

__

Why: The suggestion correctly points out that deriving PartialEq and Eq would allow for direct comparison of the enum, which is a good practice. It also correctly suggests removing the manual Copy and Clone implementations in favor of deriving them, simplifying the code.

Low
Add lint allows at top

Add a module-level #![allow(...)] attribute to suppress common lint warnings for
non-standard naming conventions and dead code in this FFI-related file.

thirdparty/crates/libc-0.2.180/src/unix/bsd/freebsdlike/freebsd/mod.rs [1-5]

+#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals, dead_code)]
 use crate::prelude::*;
 use crate::{
     cmsghdr,
     off_t,
 };
  • Apply / Chat
Suggestion importance[1-10]: 5

__

Why: This suggestion improves code quality by silencing expected lints in an FFI-heavy file, reducing noise and making legitimate warnings more visible.

Low
  • More

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.73%. Comparing base (e5b02cc) to head (b786e67).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #446      +/-   ##
==========================================
+ Coverage   88.83%   91.73%   +2.89%     
==========================================
  Files         831      830       -1     
  Lines       36977    36953      -24     
==========================================
+ Hits        32848    33897    +1049     
+ Misses       4129     3056    -1073     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant